package part1.language_basis.day04;


import java.util.Random;
import java.util.Scanner;

//猜数字小游戏
public class Guessing {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
//        Random random = new Random();
//        int nu = random.nextInt(1000)+1;
        int num = (int) (Math.random() * 1000 + 1);//1到1000之内的整数
        System.out.println(num);


        /*

        System.out.println("猜吧！");
        int guess = scanner.nextInt();
        while (guess!=num){
            if (guess>num){
                System.out.println("猜大了！");
            }else {
                System.out.println("猜小了！");
            }
            System.out.println("猜吧！");
            guess = scanner.nextInt();
        }
        System.out.println("恭喜你猜对了！");

         */

        int guess;
        do {
            System.out.println("猜吧!");
            guess = scanner.nextInt();
            if (guess > num) {
                System.out.println("猜大了");
            } else if (guess < num) {
                System.out.println("猜小了");
            }else {
                System.out.println("恭喜你猜对了");
            }
        } while (guess != num);

    }
}
